package com.zh.proxymode.services.dynamicproxy;

import com.zh.proxymode.services.dynamicproxy.impl.DiDi;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class CallPlatform implements InvocationHandler {

    private Object target;

    public Object getInstance(Object target){
        this.target = target;

        Class<?> cla = target.getClass();
        return Proxy.newProxyInstance(cla.getClassLoader(), cla.getInterfaces(), this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object obj = method.invoke(this.target,args);
        return obj;
    }
}
